package com.tanggh.listener;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

import com.tanggh.entity.City;
import com.tanggh.service.CityService;
import com.tanggh.util.CacheUtils;


public class InitListener implements ApplicationListener<ApplicationEvent> {

	@Autowired
	private CityService cityService;
	
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		List<City> list = cityService.listAll();
		for(City c : list) {
			CacheUtils.put(c.getCode(), c);
		}
		System.out.println("InitListener.onApplicationEvent() 初始化城市完毕...");
	}


}
